package com.wushi.lenovo.asia5b.app_model.good.goodbean;

import android.text.TextUtils;

import java.io.Serializable;

/**
 * Created by zhangyuncai on 2018/11/21.
 * 商品信息
 */
public class GoodsModel extends GoodsModelIml implements Serializable {
    private boolean isChecked = false;

    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }

    /**
     * option字段不是空的，attr_name 却是空的时候不能点击
     *
     * @return
     */
    public boolean canCheck() {
        if (!TextUtils.isEmpty(option) && TextUtils.isEmpty(attr_name)) {
            return false;
        }
        return true;
    }

    private int id;//购物车的id,或者包裹id
    private int product_id;//商品id
    private int quantity;//数量
    private String attr_name;//商品属性对象名称
    private String option;//商品属性对象
    private String remark;//备注
    private String name;//商品名称
    private String total;//不带单位的总价 单价*数量,todo 有的接口带单位,晕死
    private String total_value;//不带单位的总价 单价*数量
    private String total_text;//带单位的总价 单价*数量
    private String price_value;//不带单位的单价
    private String price;//带单位的单价
    private String image;//封面图
    private String is_sensitive;//Not sensitive = 0, Is sensitive = 1
    private String domestic_fee;//中国物流价格 0.0
    private String domestic_fee_format;//中国物流价格 RM 0.0
    private String m3_weight;//总体积
    private String actual_weight;//总重量
    private String dimension_weight;//总体积重
    private String total_plus_domestic;//包裹详情总计价格
    private String diff_total;//总的差价
    private String source;//商品来源
    private int sell_case_value;//一套数量

    public int getSell_case_value() {
        return sell_case_value;
    }

    public boolean is1688() {
        return TextUtils.equals(source, "1688");
    }

    public String getDomestic_fee_format() {
        return domestic_fee_format;
    }

    public String getPrice() {
        return price;
    }

    @Override
    public String goodsName() {
        return name;
    }

    @Override
    public int goodsId() {
        return product_id;
    }

    @Override
    public String goodsImg() {
        return image;
    }

    @Override
    public int parcelno() {
        return id;
    }

    @Override
    public String goodsAttr() {
        return attr_name;
    }


    @Override
    public String goodsUnitPrice() {
        return containsRM(price);
    }

    @Override
    public String goodsTotalPrice() {
        if (!TextUtils.isEmpty(total_text)) {
            return containsRM(total_text);
        }
        return containsRM(total);
    }

    @Override
    public int goodsQuantity() {
        return quantity;
    }

    public boolean isMingan() {
        return TextUtils.equals(is_sensitive, "1");
    }

    @Override
    public String chinaDeliveryFee() {
        return containsRM(domestic_fee_format);
    }

    @Override
    public String totalDiffPrice() {
        if (!TextUtils.isEmpty(diff_total)) {
            return containsRM(diff_total);
        }
        return null;
    }

    @Override
    public String zongjiPrice() {
        return containsRM(total_plus_domestic);
    }

    @Override
    public String goodsTotalWeight() {
        return containsKG(actual_weight);
    }

    @Override
    public String goodsTotalVolWeight() {
        return containsKG(dimension_weight);
    }

    @Override
    public String goodsTotalM3Weight() {
        return containsM3(m3_weight);
    }

    public int getId() {
        return id;
    }

    public String getTotal_text() {
        return total_text;
    }

    public int getProduct_id() {
        return product_id;
    }


    public int getQuantity() {
        return quantity;
    }


    public String getAttr_name() {
        return attr_name;
    }


    public String getOption() {
        return option;
    }


    @Override
    public String getRemark() {
        return remark;
    }


    public String getName() {
        return name;
    }

    public float getTotalF() {
        try {
            return Float.parseFloat(total_value);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }

    public String getImage() {
        return image;
    }


    @Override
    public String toString() {
        return "GoodsModel{" +
                "isChecked=" + isChecked +
                ", id=" + id +
                ", product_id=" + product_id +
                ", quantity=" + quantity +
                ", attr_name='" + attr_name + '\'' +
                ", option='" + option + '\'' +
                ", remark='" + remark + '\'' +
                ", name='" + name + '\'' +
                ", total_value='" + total_value + '\'' +
                ", image='" + image + '\'' +
                '}';
    }

    public String getProduct_name() {
        return getName();
    }
}

/*
{
    "total_plus_domestic": "RM 52.98",
    "total_value": "52.98",
    "domestic_fee_seller": 0,
    "domestic_fee": 0,
    "domestic_fee_format": "",
    "group_domestic_fee_seller": 0,
    "group_domestic_fee": 0,
    "group_domestic_fee_format": "",
    "is_sensitive": 1,
    "price_value": "52.98",
    "type": "pending_payment",
    "order_time": "",
    "pay_different_type": "",
    "order_id": 0,
    "dimension_weight": 0,
    "insurance_amount": 0,
    "status": 0,
    "id": 152968,
    "product_id": 342018,
    "quantity": 1,
    "mp_product_id": "",
    "stock_enough": 1,
    "sku_id": null,
    "weight": 0,
    "sku_stock": 556232,
    "dg_or_mp": "dg",
    "brand": null,
    "sensitive_cat_id": null,
    "category_id": 39,
    "shop_id": "524634614",
    "shop_name": "依加伦服饰旗舰店",
    "attr_name": "M,2 FREE COMBINATIONS, PLEASE NOTE OR CONTACT CUSTOMER SER
    "china_attr_name": "M,2件自由组合 请自行备注或联系客服",
    "width": 0,
    "length": 0,
    "height": 0,
    "selected_weight": 0,
    "highest_weight": 0,
    "actual_weight": 0,
    "m3_weight": 0,
    "average_weight": 0,
    "weight_method": "highest",
    "weight_multiply": 1.1,
    "size_dimension": 0,
    "total_size_dimension": 0,
    "total_dimension_weight": 0,
    "kgorm3": "kg",
    "option": "20509:28315,1627207:3168636489",
    "remark": "",
    "cart_time": "2020-03-03 11:18:20",
    "name": "2件】夏季男士短袖t恤纯棉翻领潮牌polo衫条纹宽松潮流体恤衣服丅",
    "ori_name": "2件】夏季男士短袖t恤纯棉翻领潮牌polo衫条纹宽松潮流体恤衣服丅",
    "eng_name": "2 pieces] summer men's short-sleeved t-shirt cotton lapel t
    "china_name": "2件】夏季男士短袖t恤纯棉翻领潮牌polo衫条纹宽松潮流体恤衣服丅",
    "original_price": "89.00",
    "converted_price": "52.98",
    "domestic_fee_ori": "0.00",
    "unit": "RM",
    "price": "RM 52.98",
    "shipping": 1,
    "original_total": "89.00",
    "converted_total": "52.98",
    "total": "52.98",
    "total_text": "RM 52.98",
    "price_jawa": "",
    "total_text_jawa": "",
    "goods_attr": "eJydXMlyG8kR\/RUMr3aMeu8u6gRC4A4SJEhK1MVBgIu4ieImSpzgwQcf
+GUulCtx6260K33rbrQrYGtuoioW7wWT96TZOUnv5U1dHh3PjmBraHFlFNd9Ypw7nKGgXPHLAycE
    "goods_attr_china": "eJydXMtuHMcV\/RWZ2wBSv7tqtCIpkiKpEUlR1GsTcIbvhyiKlC
wcTAOVermqoI5+6V1FRFOKf19FRDjKoE567E9FQlOCdT9VQjjKoE527z9FQlOKex9VRjjKoE564i
    "url": "https:\/\/item.taobao.com\/item.htm?id=568450319629",
    "image": "\/\/img.alicdn.com\/imgextra\/i4\/2944299569\/O1CN017vMAPu2KYe
},
 */